import django.utils.timezone as timezone

from django.db import models


# Create your models here.

class spi_User(models.Model):
    user_name = models.CharField(u'用户名', max_length=30)
    user_phone = models.CharField(u'手机号', max_length=11)
    user_mail = models.EmailField(u'邮箱', blank=True)
    user_password = models.CharField(u'密码', max_length=200)
    types_dict_choice = [(0, '学生'), (1, '职场人'), ]
    user_type = models.IntegerField(u'用户身份', choices=types_dict_choice, default=0)

    def __str__(self):
        return self.user_name

    class Meta:
        verbose_name = '应聘者'
        verbose_name_plural = '应聘者'


class spi_resume(models.Model):
    user = models.ForeignKey(spi_User, on_delete=models.CASCADE)
    resume_age = models.BooleanField(u'性别', default=False,)
    resume_census = models.CharField(u'城市', max_length=10, )
    resume_birthday = models.DateField(u'出生日期',)
    resume_state = models.CharField(u'工作状态', max_length=10, )
    resume_nationality = models.CharField(u'国籍', max_length=10, )
    resume_avatar_url = models.CharField(u'头像地址', max_length=200, default='#')
    resume_annuity = models.CharField(u'当前年薪', max_length=20, default='100K'),
    resume_hope_location = models.CharField(u'期望工作地点', max_length=20, )
    resume_hope_annuity = models.CharField(u'期望年薪', max_length=20, )
    resume_hope_industry = models.CharField(u'期望行业', max_length=20, )
    resume_hope_position = models.CharField(u'期望职位', max_length=20, )
    resume_School = models.CharField(u'毕业院校', max_length=30, )
    resume_professional = models.CharField(u'专业', max_length=20, )
    resume_GraduationTime = models.DateField(u'毕业时间', default=timezone.now)
    types_dict_choice = [(0, '专科'), (1, '本科'), (2, '硕士'), (3, '博士')]
    resume_SchoolLevel = models.IntegerField(u'学历', choices=types_dict_choice, default=1)

    def __str__(self):
        return self.user.user_name+'的简历'

    class Meta:
        verbose_name = '简历'
        verbose_name_plural = '简历'


class spi_workExperience(models.Model):
    reume = models.ForeignKey(spi_resume, on_delete=models.CASCADE)
    We_CompanyName = models.CharField(u'公司名称', max_length=30)
    We_CompanyIndustry = models.CharField(u'公司行业', max_length=30)
    We_PositionName = models.CharField(u'职位名称', max_length=20)
    We_PositionType = models.CharField(u'公司类别', max_length=20)
    We_location = models.CharField(u'工作地点', max_length=20)
    We_Number = models.IntegerField(u'下属人数', default=0)
    We_EntryTime = models.DateField(u'入职日期')
    We_ResignTime = models.DateField(u'离职日期')
    We_ResponsibilityTxt = models.TextField(u'职责业绩')

    def __str__(self):
        return self.reume.user.user_name + '-' + self.We_CompanyName+'工作经历'

    class Meta:
        verbose_name = '工作经历'
        verbose_name_plural = '工作经历'


class spi_RecruitmentCompany(models.Model):
    RC_Scale = models.CharField(u'公司规模', max_length=20)
    RC_Address = models.CharField(u'公司地址', max_length=20)
    RC_Name = models.CharField(u'公司名称', max_length=20)
    RC_Synopsis = models.TextField(u'公司简介', )
    RC_Financing = models.CharField(u'融资', max_length=20)
    RC_Label = models.CharField(u'公司标签', max_length=20)
    RC_BusinessScope = models.CharField(u'公司性质', max_length=20)
    RC_RegisteredCapital = models.CharField(u'公司注册资本', max_length=20)
    RC_RegisteredTime = models.DateTimeField(u'注册时间')

    def __str__(self):
        return self.RC_Name

    class Meta:
        verbose_name = '公司基本信息'
        verbose_name_plural = '公司基本信息'

class spi_CompanyHR(models.Model):
    CHR_Name = models.CharField(u'姓名', max_length=30)
    CHR_Account = models.CharField(u'HR账户', max_length=30)
    CHR_Password = models.CharField(u'HR密码', max_length=200)
    RC = models.ForeignKey(spi_RecruitmentCompany, on_delete=models.CASCADE)

    def __str__(self):
        return self.CHR_Name+'--'+self.RC.RC_Name

    class Meta:
        verbose_name = '人事信息'
        verbose_name_plural = '人事信息'

class spi_RecruitmentInfo(models.Model):

    Company = models.ForeignKey(spi_RecruitmentCompany, on_delete=models.CASCADE)
    REC_Name = models.CharField(u'职位名称', max_length=30)
    REC_ReleaseTime = models.DateField(u'发布日期')
    REC_Type = models.CharField(u'职位类别', max_length=30)
    REC_PostDescription = models.TextField(u'职位描述')
    REC_PostAsk = models.CharField(u'职位要求', max_length=50)
    REC_Address = models.CharField(u'工作地点', max_length=10)
    REC_Wage = models.CharField(u'工资', max_length=20)

    def __str__(self):
        return self.REC_Name+'--'+self.Company.RC_Name

    class Meta:
        verbose_name = '招聘信息'
        verbose_name_plural = '招聘信息'


class spi_UserCompanyInfo(models.Model):
    types_dict_choice = [(0, '应聘'), (1, '招聘'), ]
    type = models.IntegerField(u'分类', choices=types_dict_choice, default=0)
    User = models.ForeignKey(spi_User, on_delete=models.CASCADE)
    # RC = models.ForeignKey(spi_RecruitmentCompany, on_delete=models.CASCADE)
    REC = models.ForeignKey(spi_RecruitmentInfo, on_delete=models.CASCADE)

    def __str__(self):
        return self.User.user_name+'--'+str(self.type)+'--' + self.REC.REC_Name

    class Meta:
        verbose_name = '应聘/招聘信息表'
        verbose_name_plural = '应聘/招聘信息表'
